home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / LiveFastStartServer / Open Transport 1.3 / Includes / CIncludes / OpenTptAppleTalk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-30  |  20.4 KB  |  751 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OpenTptAppleTalk.h
  3.  
  4.     Contains:    Public AppleTalk definitions
  5.  
  6.     Copyright:    © 1993-1997 by Apple Computer, Inc., all rights reserved.
  7.  
  8.  
  9. */
  10.  
  11. #ifndef __OPENTPTAPPLETALK__
  12. #define __OPENTPTAPPLETALK__
  13.  
  14. #ifndef __OPENTRANSPORT__
  15. #include <OpenTransport.h>
  16. #endif
  17. #if PRAGMA_ALIGN_SUPPORTED
  18. #pragma options align=mac68k
  19. #endif
  20. #if PRAGMA_IMPORT_SUPPORTED
  21. #pragma import on
  22. #endif
  23.  
  24. /*******************************************************************************
  25. ** Some prefixes for shared libraries
  26. ********************************************************************************/
  27.  
  28. #define kATalkVersion    "1.1"
  29. #define kATalkPrefix    "ot:atlk$"
  30. #define kATBinderID        "ot:atbd$"
  31.  
  32. /*******************************************************************************
  33. ** Module definitions
  34. ********************************************************************************/
  35. //
  36. // XTI Levels
  37. //
  38. #define ATK_DDP            'DDP '
  39. #define ATK_AARP        'AARP'
  40. #define ATK_ATP            'ATP '
  41. #define ATK_ADSP        'ADSP'
  42. #define ATK_ASP            'ASP '
  43. #define ATK_PAP            'PAP '
  44. #define ATK_NBP            'NBP '
  45. #define ATK_ZIP            'ZIP '
  46. //
  47. // Module Names
  48. //
  49. #define kDDPName        "ddp"
  50. #define    kATPName        "atp"
  51. #define kADSPName        "adsp"
  52. #define    kASPName        "asp"
  53. #define kPAPName        "pap"
  54. #define kNBPName        "nbp"
  55. #define kZIPName        "zip"
  56. #define kLTalkName        "ltlk"
  57. #define kLTalkAName        "ltlkA"
  58. #define kLTalkBName        "ltlkB"
  59.  
  60. /*******************************************************************************
  61. ** Protocol-specific Options
  62. **
  63. ** NOTE:
  64. ** All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  65. ** ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  66. **                OPT_INTERVAL (# Milliseconds to wait)
  67. ********************************************************************************/
  68.  
  69. #define DDP_OPT_CHECKSUM    OPT_CHECKSUM,
  70. #define DDP_OPT_SRCADDR        0x2101    /* DDP UnitDataReq Only - set src address    */
  71.                                     /* Value is DDPAddress                        */
  72.                                     
  73. #define ATP_OPT_REPLYCNT    0x2110    /* AppleTalk - ATP Resp Pkt Ct Type            */
  74.                                     /* Value is (unsigned long)  pkt count        */
  75. #define ATP_OPT_DATALEN        0x2111    /* AppleTalk - ATP Pkt Data Len Type        */
  76.                                     /* Value is (unsigned long) length            */
  77. #define ATP_OPT_RELTIMER    0x2112    /* AppleTalk - ATP Release Timer Type        */
  78.                                     /* Value is (unsigned long) timer            */
  79.                                     /* (See Inside AppleTalk, second edition    */
  80. #define ATP_OPT_TRANID        0x2113    /* Value is (unsigned long) Boolean            */
  81.                                     /* Used to request Transaction ID            */
  82.                                     /* Returned with Transaction ID on requests */
  83.  
  84. #define PAP_OPT_OPENRETRY    0x2120    /* AppleTalk - PAP OpenConn Retry count        */
  85.                                     /* Value is (unsigned long) T_YES/T_NO        */
  86.  
  87. /*******************************************************************************
  88. ** Protocol-specific events
  89. ********************************************************************************/
  90.  
  91. enum
  92. {
  93.     kAppleTalkEvent                    = kPROTOCOLEVENT | 0x10000,
  94.  
  95.     T_GETMYZONECOMPLETE                = kAppleTalkEvent+1,
  96.     T_GETLOCALZONESCOMPLETE            = kAppleTalkEvent+2,
  97.     T_GETZONELISTCOMPLETE            = kAppleTalkEvent+3,
  98.     T_GETATALKINFOCOMPLETE            = kAppleTalkEvent+4,
  99.     
  100.     //
  101.     // If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  102.     // you will receive these events on your endpoint.
  103.     // NOTE: The endpoint does not need to be bound.
  104.     //
  105.     // No routers have been seen for a while.  If the cookie is NULL,
  106.     // all routers are gone.  Otherwise, there is still an ARA router
  107.     // hanging around being used, and only the local cable has been 
  108.     // timed out.
  109.     //
  110.     T_ATALKROUTERDOWNEVENT            = kAppleTalkEvent + 51,
  111.         //
  112.         // This indicates that all routers are offline
  113.         //
  114.         kAllATalkRoutersDown            = 0,
  115.         //
  116.         // This indicates that all local routers went offline, but
  117.         // an ARA router is still active
  118.         //
  119.         kLocalATalkRoutersDown            = -1L,
  120.         //
  121.         // This indicates that ARA was disconnected, do it's router went offline,
  122.         // and we have no local routers to fall back onto.
  123.         //
  124.         kARARouterDisconnected            = -2L,
  125.     //
  126.     // We didn't have a router, but now one has come up.
  127.     // Cookie is NULL for a normal router coming up, non-NULL
  128.     // for an ARA router coming on-line
  129.     //
  130.     T_ATALKROUTERUPEVENT            = kAppleTalkEvent + 52,
  131.         //
  132.         // We had no local routers, but an ARA router is now online.
  133.         //
  134.         kARARouterOnline                = -1L,
  135.         //
  136.         // We had no routers, but a local router is now online
  137.         //
  138.         kATalkRouterOnline                = 0,
  139.         //
  140.         // We have an ARA router, but now we've seen a local router as well
  141.         //
  142.         kLocalATalkRouterOnline             = -2L,
  143.     //
  144.     // A Zone name change was issued from the router, so our
  145.     // AppleTalk Zone has changed.
  146.     //
  147.     T_ATALKZONENAMECHANGEDEVENT        = kAppleTalkEvent + 53,
  148.     //
  149.     // An ARA connection was established (cookie != NULL),
  150.     // or was disconnected (cookie == NULL)
  151.     //
  152.     T_ATALKCONNECTIVITYCHANGEDEVENT    = kAppleTalkEvent + 54,
  153.     //
  154.     // A router has appeared, and our address is in the startup
  155.     // range.  Cookie is hi/lo of new cable range.
  156.     //
  157.     T_ATALKINTERNETAVAILABLEEVENT    = kAppleTalkEvent + 55,
  158.     //
  159.     // A router has appeared, and it's incompatible withour
  160.     // current address.  Cookie is hi/lo of new cable range.
  161.     //
  162.     T_ATALKCABLERANGECHANGEDEVENT    = kAppleTalkEvent + 56
  163.     //
  164.     // A bad router has appeared/disappeared on our network.
  165.     //
  166. };
  167.  
  168. #define IsAppleTalkEvent(x)            ((x) & 0xffff0000) == kAppleTalkEvent)
  169.  
  170. /*******************************************************************************
  171. ** Protocol-specific IOCTLs
  172. ********************************************************************************/
  173. //
  174. // Turn on/off full self-send (it's automatic for non-backward-compatible links)
  175. //
  176. #define ATALK_IOC_FULLSELFSEND            MIOC_CMD(MIOC_ATALK,47)
  177. //
  178. // ADSP Forward Reset
  179. //
  180. #define    ADSP_IOC_FORWARDRESET            MIOC_CMD(MIOC_ATALK,60)
  181.  
  182. /*******************************************************************************
  183. ** Protocol-specific constants
  184. ********************************************************************************/
  185.  
  186. enum
  187. {
  188.     /*    -------------------------------------------------------------------------
  189.         ECHO
  190.         ------------------------------------------------------------------------- */
  191.  
  192.     kECHO_TSDU                = 585,        // Max. # of data bytes.
  193.  
  194.     /*    -------------------------------------------------------------------------
  195.         NBP
  196.         ------------------------------------------------------------------------- */
  197.  
  198.     kNBPMaxNameLength        = 32,
  199.     kNBPMaxTypeLength        = 32,
  200.     kNBPMaxZoneLength        = 32,
  201.     kNBPSlushLength            = 9,    // Extra space for @, : and a few escape chars
  202.     kNBPMaxEntityLength        = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + 3),
  203.     kNBPEntityBufferSize    = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + kNBPSlushLength),
  204.     kNBPWildCard            = 0x3D,        // NBP name and type match anything '='
  205.     kNBPImbeddedWildCard    = 0xC5,        // NBP name and type match some '≈'
  206.     kNBPDefaultZone            = 0x2A,        // NBP default zone '*'
  207.  
  208.     /*    -------------------------------------------------------------------------
  209.         ZIP
  210.         ------------------------------------------------------------------------- */
  211.     
  212.     kZIPMaxZoneLength        = kNBPMaxZoneLength,
  213.     
  214.     /*    -------------------------------------------------------------------------
  215.         Address-related values
  216.         ------------------------------------------------------------------------- */
  217.         
  218.     kDDPAddressLength        = 8,        // value to use in netbuf.len field
  219.                                         // Maximum length of AppleTalk address
  220.     kNBPAddressLength        = kNBPEntityBufferSize,
  221.     kAppleTalkAddressLength    = kDDPAddressLength + kNBPEntityBufferSize
  222. };
  223.  
  224. #define OTCopyDDPAddress(addr, dest)                \
  225.     {                                                \
  226.         ((UInt32*)(dest))[0] = ((UInt32*)(addr))[0];    \
  227.         ((UInt32*)(dest))[1] = ((UInt32*)(addr))[1];    \
  228.     }
  229.  
  230. /*******************************************************************************
  231. ** CLASS TAppleTalkServices
  232. ********************************************************************************/
  233.  
  234. #if !OTKERNEL
  235.  
  236. #ifndef __cplusplus
  237.     typedef void*    ATSvcRef;
  238. #else
  239.     class TAppleTalkServices;
  240.     typedef TAppleTalkServices*    ATSvcRef;
  241. #endif
  242.  
  243. #define kDefaultAppleTalkServicesPath    ((OTConfiguration*)-3)
  244.  
  245. #ifdef __cplusplus
  246. extern "C" {
  247. #endif
  248.  
  249. extern pascal OSStatus    OTAsyncOpenAppleTalkServices(OTConfiguration* cfig, OTOpenFlags flags,
  250.                                                      OTNotifyProcPtr, void* contextPtr);            
  251. extern pascal ATSvcRef    OTOpenAppleTalkServices(OTConfiguration* cfig, OTOpenFlags flags,
  252.                                                 OSStatus* err);
  253.     //
  254.     // Get the zone associated with the ATSvcRef
  255.     //
  256. extern pascal OSStatus    OTATalkGetMyZone(ATSvcRef ref, TNetbuf* zone);
  257.     //
  258.     // Get the list of available zones associated with the local cable
  259.     // of the ATSvcRef
  260.     //
  261. extern pascal OSStatus    OTATalkGetLocalZones(ATSvcRef ref, TNetbuf* zones);
  262.     //
  263.     // Get the list of all zones on the internet specified by the ATSvcRef
  264.     //
  265. extern pascal OSStatus    OTATalkGetZoneList(ATSvcRef ref, TNetbuf* zones);
  266.     //
  267.     // Stores an AppleTalkInfo structure into the TNetbuf (see later in this file)
  268.     //
  269. extern pascal OSStatus    OTATalkGetInfo(ATSvcRef ref, TNetbuf* info);
  270.  
  271. #ifdef __cplusplus
  272. }
  273.  
  274. class TAppleTalkServices : public TProvider
  275. {
  276.     public:
  277.             OSStatus    GetMyZone(TNetbuf* zone)         { return OTATalkGetMyZone(this, zone); }
  278.             OSStatus    GetLocalZones(TNetbuf* zones)    { return OTATalkGetLocalZones(this, zones); }
  279.             OSStatus    GetZoneList(TNetbuf* zones)        { return OTATalkGetZoneList(this, zones); }
  280.             OSStatus    GetInfo(TNetbuf* info)            { return OTATalkGetInfo(this, info); }
  281. };
  282.  
  283. #endif    /* _cplus */
  284. #endif    /* !OTKERNEL */
  285.  
  286. /*    -------------------------------------------------------------------------
  287.     AppleTalk Addressing
  288.     
  289.     The NBPEntity structure is used to manipulate NBP names without regard
  290.     to issues of what kind of "special" characters are in the name.
  291.     
  292.     When stored as an address in an NBPAddress or DDPNBPAddress, they are 
  293.     stored as a character string, which is currently just ASCII, but in the
  294.     future may be UniChar, or some other internationalizable scripting set.
  295.     The string following an NBPAddress or DDPNBPAddress is intended to be
  296.     suitable for showing to users, whereas NBPEntity is not.
  297.     WARNING: NBPAddress and DDPNBPAddress structures do not "know" the length
  298.     of the address.  That must have been obtained as part of a Lookup or
  299.     ResolveAddress call.
  300.     ------------------------------------------------------------------------- */
  301.  
  302.     typedef struct DDPAddress        DDPAddress;
  303.     typedef struct NBPAddress        NBPAddress;
  304.     typedef struct DDPNBPAddress    DDPNBPAddress;
  305.     
  306.     struct NBPEntity
  307.     {
  308.         UInt8    fEntity[kNBPMaxEntityLength];
  309.     };
  310.     
  311.     typedef struct NBPEntity    NBPEntity;
  312.  
  313.     /*    ---------------------------------------------------------------------
  314.         These are some utility routines for dealing with NBP and DDP addresses. 
  315.         --------------------------------------------------------------------- */
  316.     
  317.     #ifdef __cplusplus
  318.     extern "C" {
  319.     #endif
  320.     //
  321.     // Functions to initialize the various AppleTalk Address types
  322.     //
  323.     extern pascal void        OTInitDDPAddress(DDPAddress* addr, UInt16 net, UInt8 node,
  324.                                              UInt8 socket, UInt8 ddpType);
  325.     extern pascal size_t    OTInitNBPAddress(NBPAddress* addr, const char* name);
  326.     extern pascal size_t    OTInitDDPNBPAddress(DDPNBPAddress* addr, const char* name,
  327.                                                 UInt16 net, UInt8 node, UInt8 socket,
  328.                                                 UInt8 ddpType);
  329.         //
  330.         // Compare 2 DDP addresses for equality
  331.         //
  332.     extern pascal Boolean    OTCompareDDPAddresses(const DDPAddress* addr1, const DDPAddress* addr2);
  333.         //
  334.         // Init an NBPEntity to a NULL name
  335.         //
  336.     extern pascal void        OTInitNBPEntity(NBPEntity* entity);
  337.         //
  338.         // Get the length an NBPEntity would have when stored as an address
  339.         // 
  340.     extern pascal size_t    OTGetNBPEntityLengthAsAddress(const NBPEntity* entity);
  341.         //
  342.         // Store an NBPEntity into an address buffer
  343.         //
  344.     extern pascal size_t    OTSetAddressFromNBPEntity(UInt8* nameBuf, const NBPEntity* entity);
  345.         //
  346.         // Create an address buffer from a string (use -1 for len to use strlen)
  347.         //
  348.     extern pascal size_t    OTSetAddressFromNBPString(UInt8* addrBuf, const char* name, SInt32 len);
  349.         //
  350.         // Create an NBPEntity from an address buffer. False is returned if
  351.         //   the address was truncated.
  352.         //
  353.     extern pascal Boolean    OTSetNBPEntityFromAddress(NBPEntity* entity, const UInt8* addrBuf,
  354.                                                       size_t len);
  355.         //
  356.         // Routines to set a piece of an NBP entity from a character string
  357.         //
  358.     extern pascal Boolean    OTSetNBPName(NBPEntity* entity, const char* name);
  359.     extern pascal Boolean    OTSetNBPType(NBPEntity* entity, const char* typeVal);
  360.     extern pascal Boolean    OTSetNBPZone(NBPEntity* entity, const char* zone);
  361.         //
  362.         // Routines to extract pieces of an NBP entity
  363.         //
  364.     extern pascal void        OTExtractNBPName(const NBPEntity* entity, char* name);
  365.     extern pascal void        OTExtractNBPType(const NBPEntity* entity, char* typeVal);
  366.     extern pascal void        OTExtractNBPZone(const NBPEntity* entity, char* zone);
  367.                                                 
  368.     #ifdef __cplusplus
  369.     }
  370.     #endif
  371.  
  372.     enum
  373.     {
  374.         AF_ATALK_FAMILY    = 0x0100,
  375.         AF_ATALK_DDP    = AF_ATALK_FAMILY,
  376.         AF_ATALK_DDPNBP    = AF_ATALK_FAMILY + 1,
  377.         AF_ATALK_NBP    = AF_ATALK_FAMILY + 2,
  378.         AF_ATALK_MNODE    = AF_ATALK_FAMILY + 3
  379.     };
  380.  
  381. struct DDPAddress
  382. {
  383.     OTAddressType    fAddressType;        // One of the enums above
  384.     UInt16            fNetwork;
  385.     UInt8            fNodeID;
  386.     UInt8            fSocket;
  387.     UInt8            fDDPType;
  388.     UInt8            fPad;
  389. #ifndef __cplusplus
  390.  
  391. };
  392.  
  393. #else
  394.  
  395.     public:
  396.                 void            Init(const DDPAddress&);
  397.                 void            Init(UInt16 net, UInt8 node, UInt8 socket);
  398.                 void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  399.  
  400.                 void            SetSocket(UInt8);
  401.                 void            SetType(UInt8);
  402.                 void            SetNode(UInt8);
  403.                 void            SetNetwork(UInt16);
  404.             
  405.                 size_t            GetAddressLength() const;
  406.                 OTAddressType    GetAddressType() const;
  407.                 UInt8            GetSocket() const;
  408.                 UInt8            GetType() const;
  409.                 UInt8            GetNode() const;
  410.                 UInt16            GetNetwork() const;
  411.             
  412.                 Boolean            operator==(const DDPAddress&) const;
  413.                 Boolean            operator!=(const DDPAddress&) const;
  414.                 void            operator=(const DDPAddress&);
  415. };
  416.  
  417. /*
  418.  *    Inline methods for DDPAddress
  419.  */
  420.  
  421.     inline void DDPAddress::operator=(const DDPAddress& addr)
  422.     {
  423.         *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  424.         *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  425.     }
  426.     
  427.     inline Boolean DDPAddress::operator==(const DDPAddress& addr) const
  428.     {
  429.         return OTCompareDDPAddresses(&addr, this);
  430.     }
  431.     
  432.     inline Boolean DDPAddress::operator!=(const DDPAddress& addr) const
  433.     {
  434.         return !OTCompareDDPAddresses(&addr, this);
  435.     }
  436.     
  437.     inline void DDPAddress::SetSocket(UInt8 socket)
  438.     {
  439.         fSocket = socket;
  440.     }
  441.     
  442.     inline void DDPAddress::SetNode(UInt8 node)
  443.     {
  444.         fNodeID = node;
  445.     }
  446.     
  447.     inline void DDPAddress::SetType(UInt8 type)
  448.     {
  449.         fDDPType = type;
  450.     }
  451.     
  452.     inline void DDPAddress::SetNetwork(UInt16 net)
  453.     {
  454.         fNetwork = net;
  455.     }
  456.     
  457.     inline size_t DDPAddress::GetAddressLength() const
  458.     {
  459.         return kDDPAddressLength;
  460.     }
  461.     
  462.     inline OTAddressType DDPAddress::GetAddressType() const
  463.     {
  464.         return fAddressType;
  465.     }
  466.     
  467.     inline UInt8 DDPAddress::GetSocket() const
  468.     {
  469.         return fSocket;
  470.     }
  471.     
  472.     inline UInt8 DDPAddress::GetNode() const
  473.     {
  474.         return fNodeID;
  475.     }
  476.     
  477.     inline UInt8 DDPAddress::GetType() const
  478.     {
  479.         return fDDPType;
  480.     }
  481.     
  482.     inline UInt16 DDPAddress::GetNetwork() const
  483.     {
  484.         return fNetwork;
  485.     }
  486.     
  487.     inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  488.                                   UInt8 socket)
  489.     {
  490.         fAddressType = AF_ATALK_DDP;
  491.         SetNetwork(net);
  492.         SetNode(node);
  493.         SetSocket(socket);
  494.         SetType(0);
  495.     }
  496.     
  497.     inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  498.                                   UInt8 socket, UInt8 type)
  499.     {
  500.         fAddressType = AF_ATALK_DDP;
  501.         SetNetwork(net);
  502.         SetNode(node);
  503.         SetSocket(socket);
  504.         SetType(type);
  505.     }
  506.     
  507.     inline void DDPAddress::Init(const DDPAddress& addr)
  508.     {
  509.         *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  510.         *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  511.     }
  512.     
  513. #endif    /* __cplusplus */
  514.  
  515.  
  516. struct NBPAddress
  517. {
  518.     OTAddressType    fAddressType;        // One of the enums above
  519.     UInt8            fNBPNameBuffer[kNBPEntityBufferSize];
  520. #ifndef __cplusplus
  521.  
  522. };
  523.  
  524. #else
  525.  
  526.     public:
  527.                 size_t            Init();
  528.                 size_t            Init(const NBPEntity&);
  529.                 size_t            Init(const char*);
  530.                 size_t            Init(const char*, size_t len);
  531.                 Boolean            ExtractEntity(NBPEntity&, size_t len);
  532.             
  533.                 OTAddressType    GetAddressType() const;
  534. };
  535.  
  536. /*
  537.  *    Inline methods for NBPAddress
  538.  */
  539.  
  540.     inline size_t NBPAddress::Init()
  541.     {
  542.         fAddressType = AF_ATALK_NBP;
  543.         return sizeof(OTAddressType);
  544.     }
  545.     
  546.     inline size_t NBPAddress::Init(const NBPEntity& addr)
  547.     {
  548.         fAddressType = AF_ATALK_NBP;
  549.         return sizeof(OTAddressType) + OTSetAddressFromNBPEntity(fNBPNameBuffer, &addr);
  550.     }
  551.     
  552.     inline size_t NBPAddress::Init(const char* name)
  553.     {
  554.         fAddressType = AF_ATALK_NBP;
  555.         return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, -1);
  556.     }
  557.     
  558.     inline size_t NBPAddress::Init(const char* name, size_t len)
  559.     {
  560.         fAddressType = AF_ATALK_NBP;
  561.         return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len);
  562.     }
  563.     
  564.     inline Boolean NBPAddress::ExtractEntity(NBPEntity& entity, size_t len)
  565.     {
  566.         return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  567.     }
  568.         
  569.     inline OTAddressType NBPAddress::GetAddressType() const
  570.     {
  571.         return fAddressType;
  572.     }
  573.     
  574. #endif    /* __cplusplus */
  575.  
  576. struct DDPNBPAddress
  577. {
  578.     OTAddressType    fAddressType;        // One of the enums above
  579.     UInt16            fNetwork;
  580.     UInt8            fNodeID;
  581.     UInt8            fSocket;
  582.     UInt8            fDDPType;
  583.     UInt8            fPad;
  584.     UInt8            fNBPNameBuffer[kNBPEntityBufferSize];
  585.  
  586. #ifndef __cplusplus
  587.  
  588. };
  589.  
  590. #else
  591.  
  592.     public:
  593.                 void            Init(const DDPAddress&);
  594.                 void            Init(UInt16 net, UInt8 node, UInt8 socket);
  595.                 void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  596.  
  597.                 void            SetSocket(UInt8);
  598.                 void            SetType(UInt8);
  599.                 void            SetNode(UInt8);
  600.                 void            SetNetwork(UInt16);
  601.                 
  602.                 OTAddressType    GetAddressType() const;
  603.                 UInt8            GetSocket() const;
  604.                 UInt8            GetType() const;
  605.                 UInt8            GetNode() const;
  606.                 UInt16            GetNetwork() const;
  607.                 
  608.                 Boolean            ExtractEntity(NBPEntity&, size_t len);
  609.                 size_t            SetNBPEntity(const NBPEntity&);
  610.                 size_t            SetNBPEntity(const char*);
  611.                 size_t            SetNBPEntity(const char*, size_t len);
  612.                 
  613.                 Boolean            operator==(const DDPAddress&) const;
  614. };
  615.  
  616. /*
  617.  *    Inline methods for DDPNBPAddress
  618.  */
  619.     inline Boolean DDPNBPAddress::operator==(const DDPAddress& addr) const
  620.     {
  621.         return OTCompareDDPAddresses((const DDPAddress*)this, &addr);
  622.     }
  623.     
  624.     inline void DDPNBPAddress::SetSocket(UInt8 socket)
  625.     {
  626.         fSocket = socket;
  627.     }
  628.     
  629.     inline void DDPNBPAddress::SetNode(UInt8 node)
  630.     {
  631.         fNodeID = node;
  632.     }
  633.     
  634.     inline void DDPNBPAddress::SetType(UInt8 type)
  635.     {
  636.         fDDPType = type;
  637.     }
  638.     
  639.     inline void DDPNBPAddress::SetNetwork(UInt16 net)
  640.     {
  641.         fNetwork = net;
  642.     }
  643.     
  644.     inline OTAddressType DDPNBPAddress::GetAddressType() const
  645.     {
  646.         return fAddressType;
  647.     }
  648.     
  649.     inline UInt8 DDPNBPAddress::GetSocket() const
  650.     {
  651.         return fSocket;
  652.     }
  653.     
  654.     inline UInt8 DDPNBPAddress::GetNode() const
  655.     {
  656.         return fNodeID;
  657.     }
  658.     
  659.     inline UInt8 DDPNBPAddress::GetType() const
  660.     {
  661.         return fDDPType;
  662.     }
  663.     
  664.     inline UInt16 DDPNBPAddress::GetNetwork() const
  665.     {
  666.         return fNetwork;
  667.     }
  668.     
  669.     inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  670.                                     UInt8 socket)
  671.     {
  672.         fAddressType = AF_ATALK_DDPNBP;
  673.         SetNetwork(net);
  674.         SetNode(node);
  675.         SetSocket(socket);
  676.         SetType(0);
  677.     }
  678.     
  679.     inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  680.                                     UInt8 socket, UInt8 type)
  681.     {
  682.         fAddressType = AF_ATALK_DDPNBP;
  683.         SetNetwork(net);
  684.         SetNode(node);
  685.         SetSocket(socket);
  686.         SetType(type);
  687.     }
  688.     
  689.     inline void DDPNBPAddress::Init(const DDPAddress& addr)
  690.     {
  691.         fAddressType = AF_ATALK_DDPNBP;
  692.         SetNetwork(addr.GetNetwork());
  693.         SetNode(addr.GetNode());
  694.         SetSocket(addr.GetSocket());
  695.         SetType(addr.GetType());
  696.         fNBPNameBuffer[0] = 0;
  697.     }
  698.     
  699.     inline size_t DDPNBPAddress::SetNBPEntity(const NBPEntity& entity)
  700.     {
  701.         return OTSetAddressFromNBPEntity(fNBPNameBuffer, &entity) + kDDPAddressLength;
  702.     }
  703.     
  704.     inline size_t DDPNBPAddress::SetNBPEntity(const char* name)
  705.     {
  706.         return OTSetAddressFromNBPString(fNBPNameBuffer, name, -1) + kDDPAddressLength;
  707.     }
  708.     
  709.     inline size_t DDPNBPAddress::SetNBPEntity(const char* name, size_t len)
  710.     {
  711.         return OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len) + kDDPAddressLength;
  712.     }
  713.     
  714.     inline Boolean DDPNBPAddress::ExtractEntity(NBPEntity& entity, size_t len)
  715.     {
  716.         return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  717.     }
  718.  
  719. #endif    /* __cplusplus */
  720.  
  721. /*    -------------------------------------------------------------------------
  722.         AppleTalkInfo - filled out by the OTGetATalkInfo function
  723.     ------------------------------------------------------------------------- */
  724.  
  725. struct AppleTalkInfo
  726. {
  727.     DDPAddress    fOurAddress;        // Our DDP address (network # & node)
  728.     DDPAddress    fRouterAddress;        // The address of a router on our cable
  729.     UInt16        fCableRange[2];        // The current cable range
  730.     UInt16        fFlags;                // See below
  731. };
  732.  
  733. //
  734. // For the fFlags field in AppleTalkInfo
  735. //
  736. enum
  737. {
  738.     kATalkInfoIsExtended    = 0x0001,    // This is an extended (phase 2) network
  739.     kATalkInfoHasRouter        = 0x0002,    // This cable has a router
  740.     kATalkInfoOneZone        = 0x0004    // This cable has only one zone
  741. };
  742.  
  743. #if PRAGMA_ALIGN_SUPPORTED
  744. #pragma options align=reset
  745. #endif
  746. #if PRAGMA_IMPORT_SUPPORTED
  747. #pragma import off
  748. #endif
  749.  
  750. #endif    /*  __OPENTPTAPPLETALK__ */
  751.